/**
 * Created by John on 2016/7/11.
 */
var mongo = new Mongo("localhost");
var wordsDB = mongo.getDB("BeginningMongoDB");
wordsColl = wordsDB.getCollection("word_stats");

wordsDB.runCommand({getLastError: 1, w: 1, j: true, wtimeout: 1000});

print('Before Delete One:');
var newCategory = {category: 'New'};
var projection = {word: 1};
var cursor = wordsColl.find(newCategory, projection);
printjson(cursor.toArray());

wordsColl.remove({category: 'New'}, true);
cursor = wordsColl.find(newCategory, projection);
print('After Delte One:');
printjson(cursor.toArray());

wordsColl.remove({category: 'New'});
cursor = wordsColl.find(newCategory, projection);
print('After Delte All:');
printjson(cursor.toArray());